package cn.xiaolang.function.design_pattern.strategyAdapter;

import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;

/**
 * 结算工厂
 *
 * @author Dean
 * @date 2016-01-17
 */
public class SettlementFactory {

    private static SettlementFactory factory = new SettlementFactory();

    private SettlementFactory() {
    }

    public static SettlementFactory getInstance() {
        return factory;
    }

    private static Map<PayTypeEnum, OrderSettlement> strategyMap = new EnumMap<>(PayTypeEnum.class);

    static {
        strategyMap.put(PayTypeEnum.PAY_BANK, new SettleBank());
        strategyMap.put(PayTypeEnum.PAY_ALI_PAY, new SettleAliPay());
        strategyMap.put(PayTypeEnum.PAY_WEB_CHAT, new SettleWebChat());
    }

    OrderSettlement getStrategy(PayTypeEnum payType) {
        return strategyMap.get(payType);
    }
}
